// ignore: file_names
class PostModel {
  final String post_id;
  final String post_title;
  final String post_detail;
  final List<String> post_content_list;
  final String post_image_list;
  final String post_created_time;
  final String user_id;

  const PostModel({
    required this.post_id,
    required this.post_title,
    required this.post_detail,
    required this.post_content_list,
    required this.post_image_list,
    required this.post_created_time,
    required this.user_id,
  });

  factory PostModel.fromJson(Map<String, dynamic> json) {
    return PostModel(
      post_id: json['postId'],
      post_title: json['postTitle'],
      post_detail: json['postDetail'],
      post_content_list: json['postContentList']?.cast<String>() ?? [],
      post_image_list: json['postImageList'],
      post_created_time: json['postCreatedTime'],
      user_id: json['userId'],
    );
  }

  Map<String, dynamic> toJson() => {
    'postId': post_id,
    'postTitle': post_title,
    'postDetail': post_detail,
    'postContentList': post_content_list,
    'postImageList': post_image_list,
    'postCreatedTime': post_created_time,
    'userId': user_id,
  };

  PostModel copyWith({
    String? post_id,
    String? post_title,
    String? post_detail,
    List<String>? post_content_list,
    String? post_image_list,
    String? post_created_time,
    String? user_id,
  }) {
    return PostModel(
      post_id: post_id ?? this.post_id,
      post_title: post_title ?? this.post_title,
      post_detail: post_detail ?? this.post_detail,
      post_content_list: post_content_list ?? this.post_content_list,
      post_image_list: post_image_list ?? this.post_image_list,
      post_created_time: post_created_time ?? this.post_created_time,
      user_id: user_id ?? this.user_id,
    );
  }

  @override
  String toString() =>
      'PostModel(post_id: $post_id, post_title: $post_title, post_detail: $post_detail, post_content_list: $post_content_list, post_image_list: $post_image_list, post_created_time: $post_created_time, user_id: $user_id)';
}
